package com.mysoft.gfyx.clue.controller;

import com.mysoft.framework.modeling.dataapi.OptionDataApi;
import com.mysoft.framework.modeling.dto.OptionItem;
import com.mysoft.framework.mvc.api.Controller;
import com.mysoft.framework.rpc.annotation.PubService;
import com.mysoft.framework.rpc.contants.RequestPrefix;
import com.mysoft.gfyx.clue.service.OpptySubsService;
import com.mysoft.gfyx.clue.service.dto.SubsNameDto;
import io.swagger.v3.oas.annotations.tags.Tag;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

//商机订阅控制器
@PubService(value = "/opptySubsCustomerDataOptionDataApi", prefix = RequestPrefix.API)
@Tag(name = "商机订阅潜在客户-API")
public class OpptySubsCustomerDataOptionDataApiController extends Controller implements OptionDataApi {

    @Resource
    private OpptySubsService opptysubsService;

    @Override
    public List<OptionItem> load() {
        List<SubsNameDto> subsNameList = opptysubsService.getSubsNameList(0);
        System.out.println("subsNameList===="+ subsNameList);
        List<OptionItem> list = new ArrayList<>();
        if (subsNameList.size() == 0) {
            return null;
        }
        for (SubsNameDto subsNameDto : subsNameList) {
            OptionItem optionItem = new OptionItem();
            optionItem.setText(subsNameDto.getSubsNameCountText());//显示文本
            optionItem.setValue(subsNameDto.getOpptySubsGUID().toString());//对应的值
            list.add(optionItem);
        }
        return list;
    }
}
